|
|
|
|
|
|
|
Print command, the program uses SetPrinterScale and the picture drawing routine DrawPicture to print the curve at its current dimensions. |
|
|
|
|
|
|
|
|
The left side of Figure 5.6 shows an image of program FrmPrint running on a screen. On the right is a picture showing how the curve fits on a printed page. The two pictures are not drawn at the same scale. The dashed lines indicate where the edges of the form's drawing area are on the printed page. |
|
|
|
|
|
|
|
|
In some programs, you may want to enlarge or reduce the size of a form when printing it. You might want to make the form as large as possible without changing its shape. You can achieve these goals using techniques similar to those described in the previous section. |
|
|
|
|
|
|
|
|
First, use the form or picture box object's ScaleX and ScaleY methods to get the object's dimensions in twips. Use the printer's ScaleX and ScaleY methods to convert the printer's size into twips. |
|
|
|
|
|
|
|
|
Next, compare the aspect ratios (height divided by width) of the object and the printer. If the object is relatively tall and thin, draw the object on the printer as tall as possible, making it as wide as necessary to preserve its aspect ratio. |
|
|
|
|
|
|
|
|
Similarly, if the object is relatively short and wide, draw it as wide as possible on the printer and make the object's height match. |
|
|
|
|
|
|
|
|
Once you know how large to make the object on the printer, determine where the center of the form is as before and invoke the printer's Scale method to set the scaling properties. |
|
|
|
|
|
|
|
|
The following SetLargePrinterScale subroutine performs these steps. It sets the printer's scale properties to make an object as large as possible while preserving the object's shape. |
|
|
|
|
|
|
|
|
Figure 5.6
Screen and printed output from program FrmPrint. |
|
|
|
|
|